Skip to main content

Full text of "Programming"

See other formats


Build your own Arduino-Controlled Robot! 



.1 



Make Projects 



build, hack, tweak, share, discover. 



Build your own Arduino- 



Controlled Robot! 



Written By: Nick Brenn 



TOOLS: 



Screwdriver (Flat and Phillips) (1) 
Solder (1) 
Soldering iron (1) 



PARTS: 



Arduino Uno (1) 

4WD Arduino Compatible Mobile 
Platform (1) 

PING))) Ultrasonic Sensor (1) 

MotorShield for Arduino Kit (1) 

Batteries. AA (5) 



SUMMARY 

Robotics can be a difficult hobby to jump into, but the Arduino and the 4WD Robot Platform 
make it easy for you to build an awesome robot without a struggle! By utilizing components 
found in the Maker Shed , this guide makes it easy for you to learn the basics of robotics, 
applications of the Arduino, and the process of building something awesome to show your 
family and friends. 

Here is the code on GitHub 



© Make Projects 



www.makeprojects.com 



Pagel of 21 



Build your own Arduino-Controlled Robot! 



Step 1 — Gather your Platform Parts 




• Open up the bag of parts for the 
mobile platform. You'll notice that 
there are no instructions included, 
so I will help to guide you through 
the build process. 



Step 2 — Separate your Screws 





• Open up the small plastic bag, and take out all of the metal screws, and separate the 
screws that are alike. 

• Separate the washers and the nuts as well. By isolating everything, it helps you to figure 
out where they end up being used. 



© Make Projects 



www.makeprojects.com 



Page 2 of 21 



Build your own Arduino-Controlled Robot! 



Step 3 — Attaching the Motors 




• Find the two narrow metal pieces, 
and gather your motors. There is a 
small yellow hole on the motor, and 
a hole for the axle. 

• Take one of the longer screws, and 
push it through from the outside of 
the metal, into the holes on the 
motor. The smaller washers and 
the smaller nuts will go with the 
longer screws. 

• Do this for each motor. 

• You will probably have extra 
screws or parts with the 
project, so don't get worried if you 
find extras. 



© Make Projects 



www.makeprojects.com 



Page 3 of 21 



Build your own Arduino-Controlled Robot! 



Step 4 — Wiring up the Motor 




• Find the long strand of wire from your stash of parts. Cut five equal strands of this wire 
and strip the ends of each side. 

• Four strands will be used for the four motors, while the fifth will be used for the switch. 

• Connect the two leads of the hookup wire to each of the leads on the motor. Take a 
soldering iron and solder the wires to the leads on the motor. Do this for each motor. 

• Go into your Minitronics: Survival Packs and get a 0.1 uf capacitor from each. They are 
labeled with a 104. After some research, I discovered that having a 0.1 uf capacitor 
soldered across each lead on the motor will make sure they do not move at random 
intervals. So, just insert a capacitor into each motor lead as shown in the picture. 

• Make sure that you are careful when soldering with the motors. The leads on the 
motor are fragile, so just be careful when attaching the wires to solder. 



A 



© Make Projects 



www.makeprojects.com 



Page 4 of 21 



Build your own Arduino-Controlled Robot! 



Step 5 — Wire up your Toggle Switch 




• Attach the remaining piece of hookup wire to two consecutive leads on the toggle switch. 

• Now find the half of the hexagonal metal piece with the two holes in the middle. Remove 
the nut and washer and place the toggle switch through the hole. Replace the nut and 
washer. 



Step 6 — Screwing in the Main Frame 




• Now gather eight of the smaller screws, and gather your octagonal metal pieces. The 
pieces should fit right together, and the holes on the edges should line up for the screws to 
fit into. 

• Inert a screw on each side, and then insert the screws all the way around until you have a 
rectangular main frame for your platform. 



© Make Projects 



www.makeprojects.com 



Page 5 of 21 



Build your own Arduino-Controlled Robot! 



Step 7 — Attach the Bottom Cover 






• Find the rectangular cover with six holes in it, with four on the edges. 

• Place it over one side of the main frame and screw four screws into the holes that 
matched up. Note: the two remaining holes will be used for the battery holder. 

Step 8 — Mounting the Battery Holder 




• The battery holder should be placed inside of the main frame, with the two wires of the 
battery holder facing the two wires of the toggle switch. 

• Insert the two flathead screws that came in the original pack of screws. Push them through 
the holes in the battery holder and then place a nut and a washer on the other end. 

• Don't screw them in too tight, because you do not want to crack the plastic battery holder. 



© Make Projects 



www.makeprojects.com 



Page 6 of 21 



Build your own Arduino-Controlled Robot! 



Step 9 — Wiring the Power Switch to the Battery Holder 




• Connect the red wire from the battery holder to the middle wire on the toggle switch. Strip 
the black wire (if it's not already stripped) and leave it for now. The same goes for the 
remaining wire on the toggle switch. 

• I recommend twisting the wires together, soldering them, and then putting some electrical 
tape over the connections. 

• Then just hide the wires inside the frame. 



Step 10 — Add Batteries to Holder 




• Since a cover will be going over the 
main frame, you will want to put the 
batteries in before we screw on the 
cover. You will need five AA 
batteries. 



© Make Projects 



www.makeprojects.com 



Page 7 of 21 



Build your own Arduino-Controlled Robot! 



Step 11 — Add the Top Cover 




• Find your top cover and place the side that has the 4 holes opposite to the toggle switch. 
This will be the front of the robot. 

• String the wires through the slots that are on both ends of the cover. I denoted one side of 
the motors with some electrical tape, as it will help us when we wire the motors. 

• Find 4 of the same type of screw that we have been using. Place the four screws through 
the 4 holes that you can see are open. Refer to the image if you need to know where 
exactly to screw it in. 



© Make Projects 



www.makeprojects.com 



Page 8 of 21 



Build your own Arduino-Controlled Robot! 



Step 12 — Solder the Motor Shield 




I ■ * SI 



i?icrS 55j 555 155 Iff 

JE, W P flf 



* 



ttmtwmmmmm 




• Now that the main chassis of the robot is built, we can get started on some of the 
electrical! The Arduino Motor Shield makes it easy to control and power your motors. 

• Find your Motor Shield kit and components, and let's get started! 
Step 13 — Resistors 




• Insert the Brown-Green- Red resistor into R1, and the Brown- Black-Orange into R2. 



© Make Projects 



www.makeprojects.com 



Page 9 of 21 



Build your own Arduino-Controlled Robot! 



Step 14 — Yellow Capacitors 




• Insert the yellow ceramic capacitors into C4, C2, and C6. Then solder these in. 

• (I had a blurry image for this step, so I am using the image from the next step in this step 
as well.) The next two components will be described in the next step. 

Step 15 — Reset button and Resistor Network. 




• The Reset button goes into the bottom left. The resistor network is inserted where it says 
RN1 . Make sure the end with the dot goes into the hole marked with the X. 



© Make Projects 



www.makeprojects.com 



Page 10 of 21 



Build your own Arduino-Controlled Robot! 



Step 16 — IC Chips 




• There are two L293D IC chips. Insert them into IC1 and IC2. Then insert the other IC, the 
74HC595, into IC3. Make sure the indented U on the IC matches up with the U on the 
circuit board. 



Step 17 — 47uF Capacitors 




• There are two black 47uF capacitors that are included in the kit. These will be inserted into 
C7 and C8. Make sure you insert them with the correct polarity. The negative side is noted 
with a gray strip, so insert that in the hole that is not noted positive on the circuit board. 



© Make Projects 



www.makeprojects.com 



Page 11 of 21 



Build your own Arduino-Controlled Robot! 



Step 18 — lOOuF Capcacitors 




• There are three 100uF capacitors included in the kit. Just as with the other capacitors, 
note the polarity when you insert them. I only had two 100uF capacitors included in my kit, 
but in my Minitronics: Survival Pack there was a 100uF capacitor. It had a higher voltage 
rating than the others, but that is fine. Solder these in. 

• While you are at it, insert the LED into its spot, labeled LED1. The longer lead is the 
positive lead, so note this when you are inserting it into the circuit board. Solder it in. 

Step 19 — Trim your Headers 




III 



iiiiij mm 

***** ** ****** 

llllllll llllllll 





• Included is a 36-pin header. Snip the header into two 8-pin headers, two 6-pin headers, two 
3-pin headers, and one 2-pin header. 

• The two 3-pin headers will be inserted into the top left of the circuit board. The shorter side 
is inserted into the board, so keep the longer leads up. 

• The 2-pin header will be inserted into the holes labeled PWR. As before, shorter side in, 
longer side out. Keep the 6-pin and 8-pin headers for a later step. 



© Make Projects 



www.makeprojects.com 



Page 12 of 21 



Build your own Arduino-Controlled Robot! 



Step 20 — The Terminal Blocks 




• There are three 2-terminal blocks and two 3-terminal blocks. One of the 2-terminal blocks 
is inserted into the EXT_PWR space. 

• On each side of the circuit board, there are terminals with 5 spots. So on each side, just 
combine a 2-terminal block and a 3-terminal block. Solder these in with the square 
openings facing outward. This is where the wires are connected into. 

• Ignore soldered in pins (headers) in on the Msheild v1.1. This can be done last, after the 
arduino and shield have been connected. Though, If you prefer you can do it now. 



© Make Projects 



www.makeprojects.com 



Page 13 of 21 



Build your own Arduino-Controlled Robot! 



Step 21 




• The remaining headers 

• Now take the remaining headers and place them in your Arduino, with the small ends 
facing upward. 

• Now place the Motor Shield over the headers connected to the Arduino, and poke the short 
leads through the holes in the shield. 

• Now solder the joints. Once these are soldered, you are ready to go. The Motor Shield can 
be removed, or kept on for now. 

• If using the uno, note how there are some pins (headers) not placed in the arduino, this is 
important. 



Step 22 — Installing Arduino Software 







JLJLJ.1J 1 1 I 


liiJ 


11 II 






»„„..} 








~ ~ " ~ 


""¥ I 




-A <EX2> 


tSH§ 


>f 




"f 






-jo.*i. ■-r7 rrn 


•"mm 


r-ra- j 






^m 


— . 
















• Install your Arduino Software if you 
haven't done so. Check out the 
Make: How-To Tuesday tutorial to 
help you set up your Arduino. 



© Make Projects 



www.makeprojects.com 



Page 14 of 21 



Build your own Arduino-Controlled Robot! 



Step 23 — Connect Motor Power to Motor Shield 




• Find the remaining lead from the 
toggle switch, and the black lead 
from the battery holder. 

• Unscrew the screws on the 
terminal block with the 2 terminals. 
Now take the black lead and insert 
it into the GND terminal. Take the 
lead from the toggle switch and 
insert it into the M+ terminal. 

• Tighten up the screws for the 
terminal, and your Arduino should 
receive power now. Hit the switch 
to make sure it turns on. 



© Make Projects 



www.makeprojects.com 



Page 15 of 21 



Build your own Arduino-Controlled Robot! 



Step 24 — Connecting the Motors to the Motor Shield 




• Take the wires that are coming 
from your motors and insert each 
set of the wires into the two outer 
terminals (in the row of 5). 

• Polarity does not matter at this 
point. When you get the motors 
running, if you discover that the 
wheel on a motor needs to rotate in 
the opposite direction just switch 
the wires that you inserted into the 
terminal. 

• All right; we have reached 
Checkpoint #1 and now we can test 
to make sure your motors and 
Arduino are working. We'll test 
these in the next step. 



Step 25 — Testing the Motors and MotorShield 

• Start by hitting the toggle switch. If the green light goes on, that means there is power to 
the Motor Shield, which means power to your motors! 

• Now we can go ahead and test the Motor Shield. Assuming that your computer has the 
Arduino program installed, we can move on. 

• Connect the Arduino to your computer, and upload the Motor_Test .pdf sketch found at 
the beginning of the project. This is just a simple loop to make sure your motors are 
working. 



A 



• Make sure your Arduino is not touching the metal surface of the chassis. I didn't 
realize this at the beginning, so my motors were just twitching randomly! So place a 
piece of cardboard underneath the Arduino to make sure nothing is being shorted out. You 
can paint the cardboard black so that it matches the chassis color. 



© Make Projects 



www.makeprojects.com 



Page 16 of 21 



Build your own Arduino-Controlled Robot! 



Step 26 — Add Upper-Level Standoffs 




• Screw in the long, bronze-colored standoffs into the screw holes that are between the pairs 
of screws on the chassis. 

• Then you can add the upper level of the frame. This can be used for the Ping sensor or 
your choice of other accessories. The improvisation is up to you. 



Step 27 — Install Front Carriage 




• The remaining metal piece that 
hasn't been installed yet is the 
piece with the multiple narrow slits. 

• On the end opposite to the toggle 
switch, there are two extra holes, 
where you can screw in the front 
carriage. 

• I'll be putting the Arduino here, but 
it is your choice. 



© Make Projects 



www.makeprojects.com 



Page 17 of 21 



Build your own Arduino-Controlled Robot! 



Step 28 — Install Sensor Mounts 




• In the bag of the screws there are 
three weird-looking metal pieces 
with a hole in each of them. I'll be 
using two of these to hold up the 
Ping sensor on the upper level of 
the robot. 

• Begin by wrapping the metal 
thoroughly in electrical tape. The 
sensor will be pretty close to the 
metal, so you don't want any shorts 
occurring. 

• I used just one screw for each 
piece, but since there are only 3 
holes, it has to be slightly off to one 
side or the other. 

• It may be easier to remove 
the upper level to screw 
these pieces in. It is tough to get 
the nuts onto the screws when the 
upper-level frame is attached. 



a 



© Make Projects 



www.makeprojects.com 



Page 18 of 21 



Build your own Arduino-Controlled Robot! 



Step 29 — Installing the Ping Sensor (Part 1) 




OQ 



<*&m 



• You are going to be connecting the Ping sensor to the Motor Shield. On the Motor Shield 
you will see 3 rows, each with 6 holes. They are marked GND, +5, and AO-5. 

• Go into your Minitronics Survival Pack and take out the replacement hookup wires. Cut off 
three pieces (I used different colors), each of a length that can go from the front carriage 
to the top level. If you are in doubt, just cut it longer than you think you need. 

• Strip both ends of each wire. Now, take one end of the first wire and insert it from the 
bottom up into one of the holes in AO-5. Solder this wire in from the top. 

• The AO-5 holes go to the analog inputs on the Arduino, but these can also be used as 
digital inputs if specified in the program (which it will be). 

• Take the second piece of wire and insert it (from the bottom up) into one hole in the GND 
row. Solder it in from the top. 

• Finally, take your last piece of wire and insert it (from the bottom up) into a hole in the 5+ 
row. Solder this in. 



© Make Projects 



www.makeprojects.com 



Page 19 of 21 



Build your own Arduino-Controlled Robot! 



Step 30 — Installing the Ping Sensor (Part 2) 




• Now poke the three wires through 
the narrow slit that is at the front of 
the robot. They connect to the 
PING sensor itself. 

• Solder each wire, being careful that 
the GND from the shield is 
soldered to the GND on the sensor. 
The 5+ on the shield connects to 
the 5+ pin on the sensor, and the 
AO-5 on the shield connects to the 
SIG pin on the sensor. 

• Wrap your hookup wire around 
each sensor lead carefully, and 
solder them. 



Step 31 — Securing the Ping Sensor 















1*F -: -*.p»9»0X.r ^T 


IS 






.O ■ r O 


j^^^^^ 


* 

m 

[ 

i,, 

7 




f;— - *-*?"* _' 


- 


- 


p 

1 


] 

_ 




._ 


i*\dhi*' 


9 I Bl Wif } 



• Now you are ready to secure the 
Ping sensor to the sensor mounts. 
I wrapped the sensor mounts with 
electrical tape to make the Ping 
sensor stay in better. 

• Make sure no wires or metal from 
the sensor is touching any other 
metal. If it is, just wrap the culprit 
in a small piece of electrical tape. 



© Make Projects 



www.makeprojects.com 



Page 20 of 21 



Build your own Arduino-Controlled Robot! 



Step 32 — Building the Arduino Power Supply 




• Find your 9V Battery holder, the battery holder plug, and the screw that holds it all 
together. 

• Unscrew the plastic piece from the plug and slide it up the two wires towards the case. It 
will be screwed on top of the plug once the wires are soldered. 

• The red wire from the holder is to be connected to the shorter lead on the plug while the 
black wire is soldered to the longer lead. 

• Crimp the two wires in the strain relief making sure that they do not short together. Then 
take the plastic housing and screw it over the metal plug. 

• Install a battery into the holder. Screw in the screw to hold the case together, and we are 
ready to go. 

Step 33 — Programming 

• I have provided a program that you can load onto your Arduino. It is in a file called 
Arduino_Robot_Code . pdf found under the "Files" section on the first page of this 
guide. This program makes the robot move forward until an object is located. The robot 
then moves backward and turns right. Then it goes forward again, repeating this process. 

• Plug the Arduino into the USB port on your computer. The 9V battery plug connects to the 
black female connector on the Arduino. 

• Compile the code, and then upload the code to the Arduino. 

• Hit the switch on the back of your robot, hit the switch on the battery supply, and you have 
an object-avoiding Arduino-powered robot! 

This document was last generated on 2012-11-01 03:24:38 AM. 



© Make Projects 



www.makeprojects.com 



Page 21 of 21